﻿<!--*********************************************************************

   Extended WPF Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license 

   This program can be provided to you by Xceed Software Inc. under a
   proprietary commercial license agreement for use in non-Open Source
   projects. The commercial version of Extended WPF Toolkit also includes
   priority technical support, commercial updates, and many additional 
   useful WPF controls if you license Xceed Business Suite for WPF.

   Visit http://xceed.com and follow @datagrid on Twitter.

  ********************************************************************-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes"
                    xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes">

   <!-- =============================================================================== -->
   <!-- ButtonChrome                                                                    -->
   <!-- =============================================================================== -->

   <Style TargetType="{x:Type chrome:ButtonChrome}">
      <Setter Property="IsTabStop" Value="False" />
      <Setter Property="SnapsToDevicePixels" Value="True" />
      <Setter Property="FocusVisualStyle" Value="{x:Null}" />
      <Setter Property="Background" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonNormalBackgroundKey}}" />
      <Setter Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonNormalOuterBorderKey}}" />
      <Setter Property="BorderThickness" Value="1" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type chrome:ButtonChrome}">
               <Grid>

                  <Border x:Name="OuterBorder" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                     <Border x:Name="InnerBorder" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding InnerCornerRadius}" BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonNormalInnerBorderKey}}" />
                  </Border>

                  <Border x:Name="MouseOverVisual" Opacity="0" Visibility="Collapsed" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonMouseOverOuterBorderKey}}" Background="{DynamicResource {x:Static themes:ResourceKeys.ButtonMouseOverBackgroundKey}}">
                     <Border x:Name="MouseOverInnerVisual" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding InnerCornerRadius}" BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonMouseOverInnerBorderKey}}" />
                  </Border>
                  <Border x:Name="PressedVisual" Opacity="0" Visibility="Collapsed" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedOuterBorderKey}}" Background="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedBackgroundKey}}">
                     <Border x:Name="PressedInnerVisual" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding InnerCornerRadius}" BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedInnerBorderKey}}" />
                  </Border>

                  <Border x:Name="FocusVisual" Opacity="0" Visibility="Collapsed" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonFocusedOuterBorderKey}}" Background="{DynamicResource {x:Static themes:ResourceKeys.ButtonFocusedBackgroundKey}}">
                     <Border x:Name="FocusInnerVisual" BorderThickness="1" CornerRadius="{TemplateBinding InnerCornerRadius}" BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonFocusedInnerBorderKey}}" />
                  </Border>

                  <ContentPresenter Margin="{TemplateBinding Padding}"
										      IsEnabled="{TemplateBinding IsEnabled}"
										      Content="{TemplateBinding Content}"
										      ContentStringFormat="{TemplateBinding ContentStringFormat}"
										      ContentTemplate="{TemplateBinding ContentTemplate}"
										      ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />

               </Grid>
               <ControlTemplate.Triggers>

                  <!-- If button is disabled, not checked, and is rendered normal -->
                  <MultiTrigger>
                     <MultiTrigger.Conditions>
                        <Condition Property="RenderEnabled" Value="False" />
                        <Condition Property="RenderChecked" Value="False" />
                     </MultiTrigger.Conditions>
                     <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonDisabledOuterBorderKey}}" />
                     <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonInnerBorderDisabledKey}}" />
                     <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlDisabledBackgroundKey}}" />
                  </MultiTrigger>

                  <!-- if button is enabled and pressed -->
                  <MultiTrigger>
                     <MultiTrigger.Conditions>
                        <Condition Property="RenderEnabled" Value="True" />
                        <Condition Property="RenderPressed" Value="True" />
                     </MultiTrigger.Conditions>
                     <MultiTrigger.EnterActions>
                        <BeginStoryboard>
                           <Storyboard>
                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Visibility">
                                 <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                    <DiscreteObjectKeyFrame.Value>
                                       <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                 </DiscreteObjectKeyFrame>
                              </ObjectAnimationUsingKeyFrames>
                              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Opacity">
                                 <LinearDoubleKeyFrame KeyTime="00:00:00.050" Value="1" />
                              </DoubleAnimationUsingKeyFrames>
                           </Storyboard>
                        </BeginStoryboard>
                     </MultiTrigger.EnterActions>
                     <MultiTrigger.ExitActions>
                        <BeginStoryboard>
                           <Storyboard>
                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Visibility">
                                 <DiscreteObjectKeyFrame KeyTime="00:00:00.115">
                                    <DiscreteObjectKeyFrame.Value>
                                       <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                 </DiscreteObjectKeyFrame>
                              </ObjectAnimationUsingKeyFrames>
                              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Opacity">
                                 <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="0" />
                              </DoubleAnimationUsingKeyFrames>
                           </Storyboard>
                        </BeginStoryboard>
                     </MultiTrigger.ExitActions>
                  </MultiTrigger>

                  <!-- if button is enabled, is not checked, the mouse is over, and not pressed -->
                  <MultiTrigger>
                     <MultiTrigger.Conditions>
                        <Condition Property="RenderEnabled" Value="True" />
                        <Condition Property="RenderChecked" Value="False" />
                        <Condition Property="RenderMouseOver" Value="True" />
                        <Condition Property="RenderPressed" Value="False" />
                     </MultiTrigger.Conditions>
                     <MultiTrigger.EnterActions>
                        <BeginStoryboard>
                           <Storyboard>
                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Visibility">
                                 <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                    <DiscreteObjectKeyFrame.Value>
                                       <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                 </DiscreteObjectKeyFrame>
                              </ObjectAnimationUsingKeyFrames>
                              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Opacity">
                                 <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="1" />
                              </DoubleAnimationUsingKeyFrames>
                           </Storyboard>
                        </BeginStoryboard>
                     </MultiTrigger.EnterActions>
                     <MultiTrigger.ExitActions>
                        <BeginStoryboard>
                           <Storyboard>
                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Visibility">
                                 <DiscreteObjectKeyFrame KeyTime="00:00:00.150">
                                    <DiscreteObjectKeyFrame.Value>
                                       <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                 </DiscreteObjectKeyFrame>
                              </ObjectAnimationUsingKeyFrames>
                              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Opacity">
                                 <LinearDoubleKeyFrame KeyTime="00:00:00.150" Value="0" />
                              </DoubleAnimationUsingKeyFrames>
                           </Storyboard>
                        </BeginStoryboard>
                     </MultiTrigger.ExitActions>
                  </MultiTrigger>

                  <!-- if button is enabled, checked, he mouse is not over, and it is not pressed -->
                  <MultiTrigger>
                     <MultiTrigger.Conditions>
                        <Condition Property="RenderEnabled" Value="True" />
                        <Condition Property="RenderChecked" Value="True" />
                        <Condition Property="RenderMouseOver" Value="False" />
                        <Condition Property="RenderPressed" Value="False" />
                     </MultiTrigger.Conditions>
                     <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedOuterBorderKey}}" />
                     <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedInnerBorderKey}}" />
                     <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedBackgroundKey}}" />
                  </MultiTrigger>

                  <!-- if button is focused, is enabled, not pressed, and the mouse is not over -->
                  <MultiTrigger>
                     <MultiTrigger.Conditions>
                        <Condition Property="RenderFocused" Value="True" />
                        <Condition Property="RenderEnabled" Value="True" />
                        <Condition Property="RenderPressed" Value="False" />
                        <Condition Property="RenderMouseOver" Value="False" />
                     </MultiTrigger.Conditions>
                     <MultiTrigger.EnterActions>
                        <BeginStoryboard>
                           <Storyboard>
                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                 <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                    <DiscreteObjectKeyFrame.Value>
                                       <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                 </DiscreteObjectKeyFrame>
                              </ObjectAnimationUsingKeyFrames>
                              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                 <LinearDoubleKeyFrame KeyTime="00:00:00.25" Value="1" />
                              </DoubleAnimationUsingKeyFrames>
                           </Storyboard>
                        </BeginStoryboard>
                     </MultiTrigger.EnterActions>
                     <MultiTrigger.ExitActions>
                        <BeginStoryboard>
                           <Storyboard>
                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                 <DiscreteObjectKeyFrame KeyTime="00:00:00.115">
                                    <DiscreteObjectKeyFrame.Value>
                                       <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                 </DiscreteObjectKeyFrame>
                              </ObjectAnimationUsingKeyFrames>
                              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                 <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="0" />
                              </DoubleAnimationUsingKeyFrames>
                           </Storyboard>
                        </BeginStoryboard>
                     </MultiTrigger.ExitActions>
                  </MultiTrigger>

                  <!-- if not rendered normally -->
                  <MultiTrigger>
                     <MultiTrigger.Conditions>
                        <Condition Property="RenderNormal" Value="False" />
                        <Condition Property="RenderChecked" Value="False" />
                     </MultiTrigger.Conditions>
                     <Setter TargetName="OuterBorder" Property="BorderBrush" Value="Transparent" />
                     <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{x:Null}" />
                     <Setter TargetName="OuterBorder" Property="Background" Value="Transparent" />
                  </MultiTrigger>

               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

</ResourceDictionary>